{% extends "base.html" %}
{% block title %}
    职员管理
{% endblock %}

{% block content %}

    <!-- Page Content -->
    <div id="page-wrapper">
        <div class="container-fluid">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header">职员管理</h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
            <div class="row">
                <div class="col-lg-12">
                    <div class="row">
                        <div class="col-lg-8">

                            {% for department in department_list %}
                            <a class="btn btn-default" href="/person?id={{ department.id }}">{{department.d_name}}</a>
                            {% endfor %}


                        </div>
                        <form role="form" class="col-lg-3" method="get" action="/person">
                            <div class="form-group input-group">
                                <input type="hidden" name="department_id" value="">
                                <input type="text" name="person_username" class="form-control" placeholder="输入要搜索的雇员的名字"
                                       value="">
                                <span class="input-group-btn">
                                    <button class="btn btn-default" type="submit">
                                        <i class="fa fa-search"></i>
                                    </button>
                                </span>
                            </div>
                        </form>
                        <div class="col-lg-1">
                            <a class="btn btn-default" href="/add_person">添加</a>
                        </div>
                    </div>
                    <div class="row">
                        <table class="table">
                            <thead>
                            <tr>
                                <th>职员用户名</th>
                                <th>职员部门</th>
                                <th>职员职位</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {% for person in person_list %}
                                <tr>
                                    <td>{{ person.username }}</td>
                                    <td>{{ person.our_position.p_depart.d_name }}</td>
                                    <td>{{ person.our_position.p_name}}</td>
                                    <td>
                                        <a class="btn btn-default" href="/detail_person/{{ person.id }}">详情</a>
                                        <a class="btn btn-default" href="/edit_person/{{ person.id }}">编辑</a>
                                        <a class="btn btn-default" href="/delete1/{{ person.id }}">删除</a>
                                    </td>
                                </tr>
                            {% endfor %}


                            </tbody>
                            <tfoot>
                            <tr>
                                <td colspan="4">
                                    <ul class="pagination">
                                        {# 进行分页页码渲染#}
                                        {% if person_obj.has_prev %}
                                        <li><a href="/person?page={{ person_obj.prev_num }}">上一页</a></li>
                                        {% endif %}
                                            {% for one in page_list %}
                                                <li {% if one == person_obj.page %} class="active" {% endif %}><a href="/person?page={{ one }}">{{ one }}</a></li>
                                            {% endfor %}
                                        {% if person_obj.has_next %}
                                        <li><a href="/person?page={{ person_obj.next_num }}">下一页</a></li>
                                        {% endif %}

                                    </ul>
                                </td>
                            </tr>
                            </tfoot>
                        </table>
                    </div>
                </div>
                <!-- /.col-lg-12 -->
            </div>
        </div>
        <!-- /.container-fluid -->
    </div>
    <!-- /#page-wrapper -->

{% endblock %}

